set -e
ALIYUN_USERNAME="wfg@1352540209748606.onaliyun.com"
ALIYUN_REGISTRY=crpi-j1babvi3yvmak32v.cn-hangzhou.personal.cr.aliyuncs.com
LOCAL_NAMESPACE="wufagang"
ALIYUN_NAMESPACE="wufagang"
IMAGE_NAME="ai-mcp-server-csdn-app"
IMAGE_TAG="1.0"

if [ -f ".local-config" ]; then
    source .local-config
else
    echo "no local config file"
fi

echo "Logging in to Aliyun Docker Registry..."
docker login --username="${ALIYUN_USERNAME}" --password="${ALIYUN_PASSWORD}" "${ALIYUN_REGISTRY}"

echo "Tagging the Docker image..."
docker tag "${LOCAL_NAMESPACE}"/"${IMAGE_NAME}":"${IMAGE_TAG}" "${ALIYUN_REGISTRY}"/"${ALIYUN_NAMESPACE}"/"${IMAGE_NAME}":"${IMAGE_TAG}"

echo "Pushing the Docker image to Aliyun Docker Registry..."
docker push "${ALIYUN_REGISTRY}"/"${ALIYUN_NAMESPACE}"/"${IMAGE_NAME}":"${IMAGE_TAG}"

echo "Docker image pushed successfully!"

echo "Logging out from Aliyun Docker Registry..."
docker logout $ALIYUN_REGISTRY


